﻿namespace MDXStudio.MdSchema
{
    using System;
    using System.Data;

    internal class MdMeasureGroupDimension
    {
        private string mCubeName;
        private eRelationCardinality mDimensionCardinality;
        private string mDimensionGranularity;
        private string mDimensionUniqueName;
        private bool mIsDimensionVisible;
        private bool mIsFactDimension;
        private eRelationCardinality mMeasureGroupCardinality;
        private string mMeasureGroupName;

        public MdMeasureGroupDimension(DataRow pRow)
        {
            this.mCubeName = (string) pRow["CUBE_NAME"];
            this.mMeasureGroupName = (string) pRow["MEASUREGROUP_NAME"];
            this.mMeasureGroupCardinality = (((string) pRow["MEASUREGROUP_CARDINALITY"]) == "MANY") ? eRelationCardinality.Many : eRelationCardinality.One;
            this.mDimensionUniqueName = (string) pRow["DIMENSION_UNIQUE_NAME"];
            this.mDimensionCardinality = (((string) pRow["DIMENSION_CARDINALITY"]) == "MANY") ? eRelationCardinality.Many : eRelationCardinality.One;
            this.mIsDimensionVisible = (bool) pRow["DIMENSION_IS_VISIBLE"];
            this.mIsFactDimension = (bool) pRow["DIMENSION_IS_FACT_DIMENSION"];
            this.mDimensionGranularity = (string) pRow["DIMENSION_GRANULARITY"];
        }

        public MdMeasureGroupDimension(string pCubeName, string pMeasureGroupName, eRelationCardinality pMeasureGroupCardinality, string pDimensionUniqueName, eRelationCardinality pDimensionCradinality, bool pIsDimensionVisible, bool pIsFactDimension, string pDimensionGranularity)
        {
            this.mCubeName = pCubeName;
            this.mMeasureGroupName = pMeasureGroupName;
            this.mMeasureGroupCardinality = pMeasureGroupCardinality;
            this.mDimensionUniqueName = pDimensionUniqueName;
            this.mDimensionCardinality = pDimensionCradinality;
            this.mIsDimensionVisible = pIsDimensionVisible;
            this.mIsFactDimension = pIsFactDimension;
            this.mDimensionGranularity = pDimensionGranularity;
        }

        public override string ToString()
        {
            return (this.mMeasureGroupName + " - " + this.mDimensionUniqueName);
        }

        public string CubeName
        {
            get
            {
                return this.mCubeName;
            }
        }

        public eRelationCardinality DimensionCardinality
        {
            get
            {
                return this.mDimensionCardinality;
            }
        }

        public string DimensionGranularity
        {
            get
            {
                return this.mDimensionGranularity;
            }
        }

        public string DimensionUniqueName
        {
            get
            {
                return this.mDimensionUniqueName;
            }
        }

        public bool IsDimensionVisible
        {
            get
            {
                return this.mIsDimensionVisible;
            }
        }

        public bool IsFactDimension
        {
            get
            {
                return this.mIsFactDimension;
            }
        }

        public eRelationCardinality MeasureGroupCardinality
        {
            get
            {
                return this.mMeasureGroupCardinality;
            }
        }

        public string MeasureGroupName
        {
            get
            {
                return this.mMeasureGroupName;
            }
        }
    }
}

